#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

typedef struct mo
{
	char name[10];
	float basic_salary;
	float float_salary;
	float paid;
}money;

void scanf_struct(money* x)
{
	scanf("%s", &x->name);
	scanf("%f", &x->basic_salary);
	scanf("%f", &x->float_salary);
	scanf("%f", &x->paid);
}

float sum(money* x)
{
	return (x->basic_salary + x->float_salary - x->paid);
}

int main()
{
	int n = 0;
	int i = 0;
	float fin_salary = 0;
	money person;
	scanf("%d", &n);
	for (i = 0;i < n;i++)
	{
		scanf_struct(&person);
		fin_salary = sum(&person);
		printf("%s %.2f\n", person.name, fin_salary);
	}
	return 0;
}